//导入models模块中的方法
const {onclick_data, getProductPie, platformClassificationOfCityData, getRankingOfCity, productClassificationOfCityData} = require('../models/all_sales')
const {initShowData, getYear, allProvince, radarData, platformClassificationData, getRanking,productClassificationData} = require('../models/province_sales')
const {getDataOfOnclick,getProductPieOfCounty} = require('../models/county_sales')
const {getWordModel} = require('../models/wordColud')

//homaPage下点击展示的所有数据
const classificationFunc = async (req, res)=>{
    let {code,level} = req.body
    let data = await onclick_data(code,level)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//homaPage初始化展示的数据
const initShowDataFunc = async (req, res)=>{
    const {province} = req.body
    let data = await initShowData(province)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })

}

//时间轴的时间
const getYearDataFunc = async (req, res)=>{
    let data = await getYear()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//省份数据
const getProvinceDataFunc = async (req, res) => {
    let data = await allProvince()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//点击county获取数据
const getCountyDataFunc = async (req, res) => {
    const {county} = req.body
    let data = await getDataOfOnclick(county)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//雷达图数据
const getRadarDataFunc = async (req, res) => {
    let data = await radarData()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//热门平台圆饼图数据
const getProductPieDataFunc = async (req, res) => {
    let {code,level} = req.body
    let data = await getProductPie(code,level)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//热门平台圆饼图数据(三级城市)
const getProductPieOfCountyDataFunc = async (req, res) => {
    let {county} = req.body
    let data = await getProductPieOfCounty(county)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//品牌分类的数据
const getPlatformClassificationDataFunc = async (req, res) => {
    let data = await platformClassificationData()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}
const getPlatformClassificationOfCityDataFunc = async (req, res) => {
    const {code,level} = req.body
    let data = await platformClassificationOfCityData(code,level)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//平台分类数据
const getProductClassificationDataFunc = async (req, res) => {
    let data = await productClassificationData()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}
const getProductClassificationOfCityDataFunc = async (req, res) => {
    const {code,level} = req.body
    let data = await productClassificationOfCityData(code,level)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//销售总量排行
const getRankingOfCityDataFunc = async (req, res) => {
    let {code,level} = req.body
    let data = await getRankingOfCity(code,level)
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}
const getRankingDataFunc = async (req, res) => {
    let data = await getRanking()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

//词云图
const getWordCloudDataFunc = async (req, res) => {
    let data = await getWordModel()
    res.send({
        meta:{
            state:200,
            msg:'查询成功'
        },
        data:data
    })
}

module.exports = {
    classificationFunc,
    initShowDataFunc,
    getYearDataFunc,
    getCountyDataFunc,
    getProvinceDataFunc,
    getRadarDataFunc,
    getProductPieDataFunc,
    getProductPieOfCountyDataFunc,
    getPlatformClassificationDataFunc,
    getPlatformClassificationOfCityDataFunc,
    getRankingOfCityDataFunc,
    getRankingDataFunc,
    getProductClassificationDataFunc,
    getProductClassificationOfCityDataFunc,
    getWordCloudDataFunc
}
